package com.shujia.day18;

/*
    后台线程：
        public final void setDaemon(boolean on)


    用户线程：优先级高于守护线程
    守护线程【后台线程】：当一个程序没有了用户线程，守护线程也就没有了
 */

class MyThread5 extends Thread{
    @Override
    public void run() {
        for(int i=1;i<=200;i++){
            System.out.println(getName()+"- "+i);
        }
    }
}

public class ThreadDemo5 {
    public static void main(String[] args) {
        MyThread5 t1 = new MyThread5();
        MyThread5 t2 = new MyThread5();
        MyThread5 t3 = new MyThread5();

        t1.setName("刘备");
        t2.setName("关羽");
        t3.setName("张飞");

        //将t2和t3线程设置为守护线程
        t2.setDaemon(true);
        t3.setDaemon(true);

        t1.start();
        t2.start();
        t3.start();
    }
}
